//
//  BoostViewController.m
//  u76ho
//
//  Created by m-air-01 on 16/2/19.
//  Copyright © 2016年 LV. All rights reserved.
//

#import "BoostViewController.h"
#import "BoostCollectionViewCell.h"
@interface BoostViewController ()<UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,CelltapDelegate>
{
    UICollectionView * _collectionView;
    CGSize size;
}

@end

@implementation BoostViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self main];
    
    // Do any additional setup after loading the view.
}
-(void)main
{
    self.view.backgroundColor = [UIColor blackColor];
    
    size = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT-64);
    UICollectionViewFlowLayout * flow = [[UICollectionViewFlowLayout alloc]init];
    flow.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    flow.minimumInteritemSpacing = 0;
    flow.minimumLineSpacing = 0;
    _collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) collectionViewLayout:flow];
    _collectionView.showsHorizontalScrollIndicator = 0;
    _collectionView.showsVerticalScrollIndicator = 0;
    _collectionView.dataSource = self;
    _collectionView.delegate = self;
    _collectionView.pagingEnabled = YES;
    _collectionView.backgroundColor = [UIColor blackColor];
    [_collectionView registerNib:[UINib nibWithNibName:@"BoostCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"BoostCollectionViewCell"];
    _collectionView.contentOffset = CGPointMake(SCREEN_WIDTH*(_i - 1), 0);
    [self.view addSubview:_collectionView];
    
    self.navigationItem.title = [NSString stringWithFormat:@"%i/%i",(int)_i,(int)_imgArr.count];
    
}
#pragma mark - _collectionViewDelegate
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return _imgArr.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    BoostCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"BoostCollectionViewCell" forIndexPath:indexPath];
    cell.delegate = self;
    cell.path = [_imgArr objectAtIndex:indexPath.item];
    cell.contenStr = _contentStr;
    return cell;
}
-(void)celldelegate
{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
//    [self.navigationController popViewControllerAnimated:YES];
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return size;
}
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    self.navigationItem.title = [NSString stringWithFormat:@"%i/%i",(int)(scrollView.contentOffset.x/SCREEN_WIDTH)+1,(int)_imgArr.count];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
